﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace ProjectEuler.Core
{
    class Program
    {
        static void Main(string[] args)
        {
            var ProblemsSolvedSoFar = new List<IProjectEulerProblem>();

            ProblemsSolvedSoFar.Add(new Problem1());
            ProblemsSolvedSoFar.Add(new Problem2());
            ProblemsSolvedSoFar.Add(new Problem3());
            ProblemsSolvedSoFar.Add(new Problem4());
            ProblemsSolvedSoFar.Add(new Problem5());
            ProblemsSolvedSoFar.Add(new Problem6());
            ProblemsSolvedSoFar.Add(new Problem7());
            ProblemsSolvedSoFar.Add(new Problem8());
            ProblemsSolvedSoFar.Add(new Problem9());
            ProblemsSolvedSoFar.Add(new Problem10());
            ProblemsSolvedSoFar.Add(new Problem11());
            ProblemsSolvedSoFar.Add(new Problem12());
            ProblemsSolvedSoFar.Add(new Problem13());
            ProblemsSolvedSoFar.Add(new Problem14());
            ProblemsSolvedSoFar.Add(new Problem15());
            ProblemsSolvedSoFar.Add(new Problem16());
            ProblemsSolvedSoFar.Add(new Problem17());
            ProblemsSolvedSoFar.Add(new Problem18());
            ProblemsSolvedSoFar.Add(new Problem19());
            ProblemsSolvedSoFar.Add(new Problem20());
            ProblemsSolvedSoFar.Add(new Problem21());
            ProblemsSolvedSoFar.Add(new Problem22());
            ProblemsSolvedSoFar.Add(new Problem67());

            long totalTicks = 0;

            foreach(var problem in ProblemsSolvedSoFar.OrderBy(p => p.Number))
            {
                Console.WriteLine("Problem " + problem.Number + ": " + problem.Description);

                var watch = new Stopwatch();
                watch.Start();
                var answer = problem.Answer;
                watch.Stop();

                totalTicks += watch.ElapsedTicks;

                Console.WriteLine("Answer " + problem.Number + ": " + answer);
                Console.WriteLine("Elapsed Time: " + new TimeSpan(watch.ElapsedTicks));
                Console.WriteLine();
            }

            Console.WriteLine("Total computing time to solve " + ProblemsSolvedSoFar.Count + " problems: " + new TimeSpan(totalTicks));
        }
    }
}
